package com.lhx.product.controller;

import com.lhx.common.core.domain.R;
import com.lhx.product.domain.Picture;
import com.lhx.product.mapper.PictureMapper;
import com.lhx.product.service.PictureService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author：李洪祥
 * @Package：com.lhx.product.controller
 * @Project：lhx-RuoYi
 * @name：PictureController
 * @Date：2024/6/7 上午9:00
 */
@RestController
@RequestMapping("/picture")
public class PictureController {

    @Autowired
    private PictureService pictureService;

    @Autowired
    private PictureMapper pictureMapper;

    /**
     * 添加照片表
     * @param picture
     * @return
     */
    @PostMapping("/add")
    @ApiOperation("添加")
    public R test(@RequestBody Picture picture) {
        pictureService.save(picture);
        return R.ok("success!");
    }

    /**
     * 修改照片表
     * @param picture
     * @return
     */
    @PostMapping("/update")
    @ApiOperation("修改")
    public R upt(@RequestBody Picture picture) {
        pictureService.updateById(picture);
        return R.ok("success!");
    }

    /**
     * 根据id获取照片信息
     * @param id
     * @return
     */
    @GetMapping("/findById/{id}")
    @ApiOperation("详情")
    public R get(@PathVariable Long id) {
        Picture picture = pictureService.getById(id);
        return R.ok(picture);
    }




}
